package com.gather.hashsets;

import com.gather.orm.Student;

import java.util.HashSet;

// 测试自定义类的HashSet去重
public class Example03 {
    public static void main(String[] args) {
        System.out.println("测试自定义类的HashSet去重");

        HashSet<Student> students = new HashSet<>();
        Student jack = new Student("1", "jack");
        students.add(jack);
        students.add(new Student("2","tom"));
        students.add(new Student("2","tom"));
        /**
         * 判断：如果id 相同，我们应该去重元素
         * 打印结果 students [1:jack, 2:tom, 2:tom]
         * 没有达到去重
         */
        System.out.println("students "+students);

        // 删除操作
        students.remove(jack);
    }
}
